<?php
/**htmlpage.class.php
 * 
 * frequently used function to create html pages
 * 
 * @author voellenk
 */

class htmlpage {
  //Style for Titlemenu
  public static $styleTM=array (
    "<table" => "<table class='titlemenu' ",
    "<th"    => "<th class='titlemenu' ",
    "<td"    => "<td class='titlemenu' ");
  public static $styleOV=array (
    "<table" => "<table class='overview' ",
    "<th"    => "<th class='overview' ",
    "<td"    => "<td class='overview' ");
  public static $styleEB=array (
    "<table" => "<table class='editbar' ",
    "<th"    => "<th class='editbar' ",
    "<td"    => "<td class='editbar' ");
  
  function __construct ($title="") {
    $this->title=$title;
  }

  //ToDo: improve
  public function htmlhead($stylefile=false) {
    $html= "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n";
    $html.="<html>\n<head>\n<title>".$this->title."</title>\n";
    if ($stylefile) {
      $html.="<link href=\"style/$stylefile\" rel=\"stylesheet\" type=\"text/css\" />\n";
    }
    $html.="<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" />\n</head>\n";
    return $html;
  }

  public function htmlbodytag($attribute="") {
    if (!$attribute) {
      return "<body>\n";
    } else {
      return "<body ".$attribute.">\n";
    }
  }
  
  public function linkToHomepage() {
    $html= "<a href='index.php'>home</a>";
    return $html;
  }

  public function htmlend() {
    return "\n</body></html>\n";
  }

  public static function addStyle($html, $style) {
    while (current($style)) {
      $search[]=key($style);
      next($style);
    }
    return str_replace ($search,$style,$html);
  }
}

?>